package com.beaven.java.sort;

import java.util.Arrays;
import java.util.Random;

/**
 * @author Beaven
 * @date 2018/7/7 17:03
 */
public class Main {

    public static void main(String[] args) {
        Random random = new Random();
        for (int i = 0; i < 100; i++) {
            int[] nums = testValue(random.nextInt(100));
            int[] numsTest = nums.clone();
            BubbleSort.sort(nums);
            Arrays.sort(numsTest);
            for (int j = 0; j < nums.length; j++) {
                if (nums[j] != numsTest[j]) {
                    System.out.println(j + "error");
                }
            }
        }
    }


    public static int[] testValue(int length) {
        int[] nums = new int[length];
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            nums[i] = random.nextInt();
        }
        return nums;
    }

}
